package com.erp.myAdapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import com.erp.bean.XiaoZuKBean
import com.erp.R
import com.erp.util.Myutil
import kotlinx.android.synthetic.main.lv_xzxiaozu.view.*


/**
 * Created by Administrator on 2017/11/11/011.
 * 作者：刘洋
 */
class XZXiaoZuKAdapter(var xiaozuList : MutableList<XiaoZuKBean>, val context : Context) : BaseAdapter(){
    var minflater: LayoutInflater = LayoutInflater.from(context)
    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        var v :View
        var h : Header
        if(convertView==null){
            v=minflater.inflate(R.layout.lv_xzxiaozu,null)
            h= Header(v)
            v.tag=h
        }else{
            v=convertView
            h=v.tag as Header
        }
        var adapter= XiaoZuKAdapter(xiaozuList[position].xiaoZuBean, context)
        h.lv.adapter=adapter
        Myutil.settv(xiaozuList[position].gnum,h.zuhaotv)
        h.lv.isFocusable=false
        h.lv.isClickable=false
        h.lv.isPressed=false
        h.lv.isEnabled=false
        return v
    }

    override fun getItem(position: Int): Any {
        return xiaozuList.get(position).xiaoZuBean
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getCount(): Int {
        return xiaozuList.size
    }
    class Header(var v : View){
        var lv=v.BenZuLv
        var zuhaotv=v.ZuHaoTv
    }
}